package com.exam.citi;

/**
 * date:
 * description:
 */
public class Solution002 {
    public static void main(String[] args) {
        Solution002 instance = new Solution002();
        String res = instance.merge(new int[]{1, 2, 3, 0, 0, 0}, 3, new int[]{2, 5, 6}, 3);
        System.out.println(res);
    }
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param nums1 int整型一维数组 integer arrays sorted in non-decreasing order
     * @param m int整型 representing the number of elements in nums1
     * @param nums2 int整型一维数组 integer arrays sorted in non-decreasing order
     * @param n int整型 representing the number of elements in nums2
     * @return string字符串
     */
    public String merge (int[] nums1, int m, int[] nums2, int n) {
        // write code here
        m--;
        n--;
        int index = nums1.length - 1;
        while(m >= 0 && n >= 0){
            if(nums1[m] >= nums2[n]){
                nums1[index--] = nums1[m--];
            }else{
                nums1[index--] = nums2[n--];
            }
        }
        while(n >= 0){
            nums1[index--] = nums2[n--];
        }
        StringBuilder sb = new StringBuilder();
        for (int num : nums1) {
            sb.append(num);
        }
        return sb.toString();
    }
}
